/**
* @author maze | guavestudios.com
* @license MIT License see LICENSE.TXT
* @version 0.1
*/
package  {
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.utils.*;
	public class Console {
		
		//{ STATIC
		static private var hostedName:String="com.guavestudios.fcon.ConsoleImpl";
		static private var hosted:Class;
		static private var host:Boolean = false;
		static private var executeList:Array=new Array();
		
		static private function getInstance():Class
		{
			if (!hosted) hosted=getDefinitionByName(hostedName) as Class;
			return hosted;
		}
		/**
		* @copy com.guavestudios.fcon.ConsoleImp#trace()
		*/
		static public function trace(s:Object):void
		{
			if (host) getInstance().trace(s);
			else executeList.push(s);
			
		}
		/**
		* @copy com.guavestudios.fcon.ConsoleImp#execute()
		*/
		static public function execute(s:*):void
		{
			if (host) getInstance().execute(s);
		}
		/**
		* @copy com.guavestudios.fcon.ConsoleImp#setStage()
		*/
		static public function setStage(s:Stage,config:XML=null):void
		{
			if (s == null)
			{
				trace("Error: (Console.setStage) fCon inited with null");
				return;
			}
			var c:Class = getInstance();
			if (c) 
			{
				host = true;
				if (config) 
					c.setStage(s,config);
				else c.setStage(s);
				
				if (executeList.length > 0)
				{
					for (var i:int = 0, len:int = executeList.length; i<len; i++)
					{
						c.trace(executeList[i]);
					}
					executeList = null;
				}
			}
			else
			{
				trace("ERROR: (Console.setStage) Hostclass was not found: "+hostedName);
			}
		}
		/**
		* Get the hosted class id
		*  
		*  @return String
		*/
		static public function getHostedName():String {
			return hostedName;
		}
		/**
		* Set the hosted class id
		*  
		*  @param phostedName[String]
		*  @return
		*/
		static public function setHostedName(phostedName:String):void {
			hostedName = phostedName;
		}
		//}
		
		//{ MEMBERS
		
		//}
		
		//{ GETTER-SETTER
		
		
		//}
		public function Console() {
			
			
			init();	
		}
		private function init():void {
			
		}
		//{ PUBLIC FUNCTIONS
		
		//}
		
		//{ OVERRIDEN METHODS
		
		//}
		
		//{ PRIVATE FUNCTIONS
		
		//}

	}
	
}
